package edu.bit.water.dao;

import java.util.Date;
import java.util.List;
import java.util.Map;

import edu.bit.water.entity.EntityWater;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Repository;

import edu.bit.water.dto.WaterCondition;

@Mapper
@Repository
public interface EntityWaterDao {

	int queryIndexData(@Param("now") String now, @Param("before") String before);
	int insertEntityWater(EntityWater entityWater) ;
	int deleteEntityWater(@Param ("idList")String s);
	List<Map<String, Object>> selectEntityWater();

	/**
	 * 这里的companyId其实对应着techProcessId
	 * @param companyId
	 * @return
	 */
	List<Map<String, Object>> selectEntityWaterByCompanyIdAndSearchContent(@Param("companyId") String companyId, @Param("begin") int begin, @Param("end") int end, @Param("searchContent") String searchContent);
	List<Map<String, Object>> selectEntityWaterByCompanyId(@Param("companyId") String companyId);
	List<Map<String, Object>> selectEntityWaterByCompanyIdSensor(@Param("companyId") String companyId, @Param("sensor") String sensor);
	int selectEntityWaterSumByCompanyIdSensor(@Param("companyId") String companyId, @Param("sensorRowId") String sensorRowId);
	List<Map<String, Object>> selectEntityWaterByCompanyIdSensor__(@Param("companyId") String companyId, @Param("sensor") String sensor, @Param("begin") int begin,
																 @Param("end") int end, @Param("searchContent") String searchContent);
	int updateEntityWater(EntityWater entityWater);
	//根据时间来查询值
	Double subtraction(@Param("time") Date time,@Param("sensor_name") String sensor_name);
	List<Map<String, Object>> selectEntityWaterByCondition(@Param("sensorRowIds")String sensorName,@Param("startTime") String startTime,@Param("endTime") String endTime, @Param("companyId") String companyId);

    Integer getMaxId();

    List<Double> queryValueBySensorRowId(@Param("businessId") String businessId, @Param("sensorRowId") String sensorRowId);
	List<Double> queryNewValueBySensorRowId(@Param("businessId") String businessId, @Param("sensorRowId") String sensorRowId);
    int selectEntityWaterSumByCompanyId(@Param("businessId") String businessId, @Param("searchContent") String searchContent);


	/**
	 * 查询该企业的设备编号列表
	 * @param businessId
	 * @return
	 */
	List<EntityWater> selectNewEntity(@Param("bussinessId") String businessId);

	/**
	 * 获取data collection中的数据
	 */
	List<Map<String, Object>> getDataCollection();

	/**
	 * 查询entity_water表中是否存在created_at为空值的情况
	 */
	List<Map<String, Object>> queryCreatedHasNull();

	int updateEntityWater__(@Param("entity") EntityWater entity);

	List<String> querySensorRowIdsByTime(@Param("date") Date date);
}
